# -*- shell-script -*-

# experimental bzr bash completion

# author: Martin Pool

_bzr_commands() 
{
     bzr help commands | sed -r 's/^([-[:alnum:]]*).*/\1/' | grep '^[[:alnum:]]' 
}

_bzr() 
{
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    if [ $COMP_CWORD -eq 1 ]; then
        COMPREPLY=( $( compgen -W "$(_bzr_commands)" $cur ) )
    elif [ $COMP_CWORD -eq 2 ]; then
        case "$prev" in 
        help)
            COMPREPLY=( $( compgen -W "$(_bzr_commands) commands" $cur ) )
            ;;
        esac
    fi 
}

complete -F _bzr -o default bzr

